package v2.chapter8.compiler;

import java.net.URI;

import javax.tools.SimpleJavaFileObject;

public class StringBuilderJavaSource extends SimpleJavaFileObject {

	private StringBuilder code;

	public StringBuilderJavaSource(String name) {
		super(URI.create("string:///" + name.replace('.', '/') + Kind.SOURCE.extension), Kind.SOURCE);
		code = new StringBuilder();
	}

	public CharSequence getCharContent(boolean ignoreEncodingErrors) {
		return code;
	}

	public void append(String str) {
		code.append(str);
		code.append('\n');
	}
}
